﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using University.Workshop.Presenters.OtbData.Modify;

namespace University.Workshop.Presentation.OTBData.Modify
{
    /// <summary>
    /// Interaction logic for ModifyOtbDataPrincipal.xaml
    /// </summary>
    public partial class ModifyOtbDataPrincipal : Page, IModifyPrincipalView
    {
        PresenterModifyOtbData pModifyOtbData;
        IModifyBasicOtbDataView ModifyBasicValue;
        public ChangeBackgroundEventHandler ChangeBackground { get; set; }

        public ModifyOtbDataPrincipal()
        {
            InitializeComponent();
            pModifyOtbData = new PresenterModifyOtbData(this);
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            frmContent.Navigate(new PageFirstStepModifyOtbData(pModifyOtbData));
            pModifyOtbData.FirstTime();
        }

        public IModifyBasicOtbDataView ModifyBasic
        {
            get
            {
                return ModifyBasicValue;
            }
            set
            {
                ModifyBasicValue = value;
            }
        }

        public void ReturnSearchOtbData()
        {
            this.NavigationService.Navigate(new SearchOtbData());
        }

        public void GoRegisterOtbData()
        {
            this.NavigationService.Navigate(new Register.RegisterOtbDataPrincipal());
        }

        public void RefreshOtbDataMainView(string path, string otbName)
        {
                this.ChangeBackground(this, path, otbName);
        }

        #region Buttons
        private void modifyBtn_Click(object sender, RoutedEventArgs e)
        {
            pModifyOtbData.ModifyOtbData();
        }

        private void btnCancelModify_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new ModifyOtbDataPrincipal());
        }

        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            pModifyOtbData.GoNextPage();
        }

        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            pModifyOtbData.GoBackPage();
        }

        private void GoStepOne_Click(object sender, RoutedEventArgs e)
        {
            pModifyOtbData.GoStepOne();
        }

        private void GoStepTwo_Click(object sender, RoutedEventArgs e)
        {
            pModifyOtbData.GoStepTwo();
        }

        #endregion

        #region Error Messages
        public void SystemMessage(string MessageValue)
        {
            MessageBox.Show(App.Current.MainWindow, MessageValue, "Atencion!!!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }

        public void ErrorMessage(string MessageValue)
        {
            MessageBox.Show(App.Current.MainWindow, MessageValue, "Error!!!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }
        #endregion

        #region Calls to Pages
        public void CallFirstPage()
        {
            PageFirstStepModifyOtbData pp = new PageFirstStepModifyOtbData(pModifyOtbData);
            ModifyBasicValue = pp;
            frmContent.NavigationService.Navigate(pp);
        }

        public void CallSecondPage()
        {
            PageSecondStepModifyOtbData pp = new PageSecondStepModifyOtbData(pModifyOtbData);
            ModifyBasicValue = pp;
            frmContent.NavigationService.Navigate(pp);
            goStepTwoBtn.IsEnabled = true;
        }
        #endregion
    }

    public delegate void ChangeBackgroundEventHandler(object sender, string newBackgroundPath, string OtbName);
}
